fix(bq_driver): Fix encoding for SAP HANA#1506
Conversation
735d19f to
873b9da
Compare
311c71e to
814c1fb
Compare
511f04e to
7b8b154
Compare
f9232a2 to
9ce5ad1
Compare
07fe46c to
c350b18
Compare
| std::regex named_pattern(R"([:@]\w+)"); | ||
|
|
||
| // Check for positional parameters | ||
| if (std::regex_search(query, positional_pattern)) { |
There was a problem hiding this comment.
Let's deep dive into the reason this was crashing.
Let's print query and positional_pattern. Let's write a small c++ application to verify that it crashes independently.
There was a problem hiding this comment.
Have verified and independently it works, issue is due to SAP HANA interfering with std::regex ABI , using re2 regex instead
3ae14c6 to
79a7205
Compare
b92e73f to
669ab63
Compare
| for (auto const& procedure_field : bq_procedure.schema.fields) { | ||
| std::regex column_pattern = BuildRegex(bq_procedure_column, metadata_id); | ||
| if (std::regex_match(procedure_field.name, column_pattern)) { | ||
| auto column_pattern = BuildRegex(bq_procedure_column, metadata_id); |
There was a problem hiding this comment.
We avoid using auto for better readability.
efcec36 to
83ddd86
Compare
83ddd86 to
337cd07
Compare
|
@sachinpro please check the PR |
| return false; | ||
| #else | ||
| if (sizeof(SQLWCHAR) != 4) return false; | ||
| return g_utf16le_wire_latched.load(std::memory_order_relaxed); |
There was a problem hiding this comment.
Please check what is the value returned here and sizeof(SQLWCHAR).
There was a problem hiding this comment.
IsRuntimeWireUtf16Le returns true here for SAP HANA and prints sizeof(SQLWCHAR) as 4 as the driver is built with iodbc where sizeof(SQLWCHAR) is 4 , and that's why we can't directly use sizeof(SQLWCHAR) as on SAP HANA system
| // later call (including the ambiguous ones from SQLTables(catalog="%")) | ||
| // honors the latch via IsRuntimeWireUtf16Le(). | ||
| if (sizeof(SQLWCHAR) == 4) { | ||
| bool use_utf16le = g_utf16le_wire_latched.load(std::memory_order_relaxed); |
There was a problem hiding this comment.
Let's read DriverManagerEncoding from googlebigqueryodbc.ini to read the encoding and WireWcharSize should use it.
Fixed the encoding which was causing the issue on SAP HANA and had a different size of SQLWCHAR that the one it was built with . Another issue was the usage of std::regex crashing the driver due conflicting ABI with SAP HANA and moved to use RE2 regex now. PR size is bigger as had to change the usage of SQLWCHAR vector wherever we were creating earlier. Windows and linux checks are run here. Have verified on windows third party tools , seems working fine